home *** CD-ROM | disk | FTP | other *** search
- unit Test1;
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, StdCtrls;
-
- type
- TForm1 = class(TForm)
- Memo1: TMemo;
- test1Button: TButton;
- test2Button: TButton;
- oopsButton: TButton;
- procedure FormCreate(Sender: TObject);
- procedure test1ButtonClick(Sender: TObject);
- procedure test2ButtonClick(Sender: TObject);
- procedure oopsButtonClick(Sender: TObject);
- private
- t : TextFile;
- s : string;
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- uses sdd;
-
- {$R *.DFM}
-
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- Memo1.Clear;
- AssignSt(t,s);
- end;
-
- procedure TForm1.test1ButtonClick(Sender: TObject);
- var
- s1,s2,s3,s4 : string[23];
- n1,n2 : byte;
- n3 : word;
- begin
- s := 'One Thing,after another,comma delimited,45 32 651,hike!';
- with memo1,lines do
- begin
- add('--- Start of test 1, s follows ---');
- add(s);
- add('--- results follow ---');
- delim(s,',',false);
- reset(t);
- readln(t,s1);
- readln(t,s2);
- readln(t,s3);
- read(t,n1);
- readln(t,n2,n3);
- readln(t,s4);
- add(s1);
- add(s2);
- add(s3);
- rewrite(t);
- write(t,n1);
- add(s);
- rewrite(t);
- write(t,n2);
- add(s);
- s := 'an append attempt:';
- append(t);
- write(t,n3);
- add(s);
- add(s4);
- end;
- end;
-
- procedure TForm1.test2ButtonClick(Sender: TObject);
- var
- s1,s2 : string[23];
- r : extended;
- begin
- s := 'string\13.21 -789 88999\more string';
- with memo1,lines do
- begin
- add('--- Start of test 2, s follows ---');
- add(s);
- add('--- results follow ---');
- delim(s,'\',false);
- reset(t);
- readln(t,s1); add(s1);
- readln(t,r); add(FloatToStr(r));
- readln(t,s2); add(s2);
- end;
- end;
-
- procedure TForm1.oopsButtonClick(Sender: TObject);
- var
- s1,s2 : string[23];
- r : extended;
- w : word;
- l : longint;
- io : integer;
- begin
- s := 'string:13.21 789.7 88999:more string';
- with memo1,lines do
- begin
- add('--- Start of oops test, s follows ---');
- add(s);
- add('--- results follow ---');
- delim(s,':',false);
- reset(t);
- readln(t,s1); add(s1);
- read(t,r); add(FloatToStr(r));
- try
- read(t,w); add(IntToStr(w));
- except
- MessageDlg('Wrong type',mtInformation,[mbOk],0);
- end;
- readln(t,l); add(IntToStr(l));
- readln(t,s2); add(s2);
- end;
- end;
-
- end.